package project.product.internal;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import project.product.Brand;
import project.product.BrandService;

public class BrandServiceImpl extends HibernateDaoSupport implements BrandService {

    @Override
    public List<Brand> getAll() {
        StringBuffer queryString = new StringBuffer(" FROM Brand WHERE shelves = ? ORDER BY order");
        return this.getHibernateTemplate().find(queryString.toString(),new Object[]{true});
    }

    @Override
    public Brand getBrand(Serializable id) {
        StringBuffer queryString = new StringBuffer(" FROM Brand where id=?");
        List<Brand> list = this.getHibernateTemplate().find(queryString.toString(), id);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }

}
